package ooday03;

public class RefArrayDemo {
    public static void main(String[] args) {
        //引用类型数组的演示
        /*int[] a=new int[3];
        System.out.println(a);
        System.out.println(a[0]);*/
        Dog[] dogs=new Dog[3];
        dogs[0]=new Dog("旺财1",1,"白");
        dogs[1]=new Dog("旺财2",2,"黄");
        dogs[2]=new Dog("旺财3",3,"黑");
        dogs[1].age=5;
        dogs[2].swim();
        for (int i=0;i<dogs.length;i++){
            System.out.println(dogs[i].name);
            dogs[i].eat();
        }
        System.out.println("--------------------------------");
        Chick[] chicks=new Chick[3];
        chicks[0]=new Chick("小黄",2,"黄");
        chicks[1]=new Chick("小黑",2,"黑");
        chicks[2]=new Chick("小红",2,"红");
        for (int i=0;i<chicks.length;i++){
            System.out.println(chicks[i].color);
            chicks[i].layEggs();
        }
        System.out.println("--------------------------------");
        Fish[] fish=new Fish[2];
        fish[0]=new Fish("泡泡",2,"粉");
        fish[1]=new Fish("泡泡2",1,"青");
        for (int i=0;i<fish.length;i++){
            System.out.println(fish[i].age);
            fish[i].swim();
        }
        /*System.out.println(dogs);
        System.out.println(dogs[0]);*/

        /*Dog[] dogs=new Dog[4];
        dogs[0]=new Dog("旺财1",1,"白");
        dogs[1]=new Dog("旺财2",2,"黄");
        dogs[2]=new Dog("旺财3",3,"黑");
        dogs[3]=new Dog("旺财4",4,"灰");

        Chick[] chicks=new Chick[3];
        chicks[0]=new Chick("小黄",2,"黄");
        chicks[1]=new Chick("小黑",2,"黑");
        chicks[2]=new Chick("小红",2,"红");

        Fish[] fish=new Fish[2];
        fish[0]=new Fish("泡泡",2,"粉");
        fish[1]=new Fish("泡泡2",1,"青");
*/

        /*Dog[] dogs=new Dog[3];
        //声明Dog类型的数组dogs,包含3个元素，每一个元素都是Dog类型，默认值为null
        Chick[] chicks=new Chick[3];
        Fish[] fishs=new Fish[2];
        */
    }
}
